package model;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Map;

import xl.Address;
import xl.XLException;

public class XLBufferedReader extends BufferedReader {
    public XLBufferedReader(String name) throws FileNotFoundException {
        super(new FileReader(name));
    }

    public void load(Map<Address, Cell> map) {
        try {
        	CellFactory myCellFactory = new CellFactory();
            while (ready()) {
                String entry[] = readLine().split("=");
                map.put(new Address(entry[0]), myCellFactory.build(entry[1]));
            }
        } catch (Exception e) {
            throw new XLException(e.getMessage());
        }
    }
}
